<template>
  <div class="page">
    <c-title :text="label_title"></c-title>
    <div class="wrapper" v-show="isLoadingEnd">
      <div class="image">
        <img :src="groupCodeInfoObj.label_banner_img"
             alt="">
      </div>
      <div class="group-wrap">
        <div class="group">
          <div class="image">
            <img v-if="groupCodeInfoObj.member_id && groupCodeInfoObj.has_one_member"
              :src="groupCodeInfoObj.has_one_member.avatar_image" alt="图片无效" />
            <img v-else :src="shop_log" alt="图片无效" />
          </div>
          <div class="content">
            <p class="name">{{groupCodeInfoObj.code_name}}</p>
            <p class="desc">已有{{groupCodeInfoObj.in_number}}人进群</p>
          </div>
          <div class="share flex-a-c" @click="openShare">
            <div class="share-box flex-a-c flex-j-c">
              <i class="iconfont icon-share"></i>
            </div>
          </div>
        </div>
        <div class="group_type">
          <div class="group_top">
            <p class="p1">选择群类型</p>
            <!-- v-if="groupCodeInfoObj.explain"-->
            <div @click="explainFlag = true" class="flex-a-c p2">
              <p >说明</p>
              <span class="iconfont icon-icon_more1"></span>
            </div>
            
          </div>
          <div class="labels">
            <div class="label"
                @click="selectedLabel(item,key)"
                v-for="(item,key) in groupCodeInfoObj.label_data"
                :key="key">
              {{item}}
            </div>
          </div>
        </div>
      </div>
      
    </div>

    <van-overlay :show="shareFlag"
                 @click="shareFlag = false">
      <div style="display: flex; align-items: center; justify-content: center; height: 100%;">
        <transition name="van-slide-up">
          <div class="shareWrapper"
               v-show="shareFlag"
               @click.stop>
            <div class="imgContent" v-if="qrCodeCanvasSrc">
              <img :src="qrCodeCanvasSrc" alt="">
            </div>
            <div v-else class="divContent">
              <div class="header">
                <div class="userInfo">
                  <div class="image">
                    <img class="img"
                         v-if="groupCodeInfoObj.member_id && groupCodeInfoObj.has_one_member"
                         :src="groupCodeInfoObj.has_one_member.avatar_image"
                         alt="图片无效" />
                    <img class="img"
                         v-else
                         :src="shop_log"
                         alt="图片无效" />
                  </div>
                  <div class="title" v-if="groupCodeInfoObj.group_code">{{groupCodeInfoObj.group_code.code_name}}</div>
                </div>
                <div class="desc" v-if="groupCodeInfoObj.group_code">
                  {{groupCodeInfoObj.group_code.code_guide}}
                </div>
              </div>
              <div class="footer">
                <share-canvas class="canvas"
                              ref="share_canvas"></share-canvas>
              </div>
            </div>

            <div class="close">
              <i class="iconfont icon-adsystem_icon_cancle"
                 @click="shareFlag = false"></i>
            </div>
          </div>
        </transition>
      </div>
    </van-overlay>

    <van-overlay :show="explainFlag" :lock-scroll="false"
                 @click="explainFlag = false">
      <div style="display: flex; align-items: center; justify-content: center; height: 100%;">
        <transition name="van-slide-up">
          <div class="explainWrapper"
               v-show="explainFlag"
               @click.stop>
            <div class="header">
              <div class="title">说明</div>
              <!-- <i class="iconfont icon-guanbi"
                 @click="explainFlag = false"></i> -->
            </div>
            <div class="content"
                 v-html="groupCodeInfoObj.explain_content">

            </div>
            <div class="poster-down"  v-show="explainFlag" @click="explainFlag = false">
              <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/poster-down.png" />
            </div>
          </div>
        </transition>
      </div>
    </van-overlay>

  </div>
</template>

<script>
import groupCodeLabelController from './group_code_label_controller.js';

export default groupCodeLabelController;
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
  .page {
    // background-color: #fff;
    min-height: 100vh;
    padding-bottom: 3.0625rem;
  }

  .wrapper {
    margin:0.75rem 0.75rem 0 0.75rem;

    .image {
      display: flex;
      justify-content: center;
      // height: 160px;
      width: 100%;

      img {
        max-width: 100%;
        width: 350px;
        height: auto;
        border-radius: 0.625rem;
      }
    }
    .group-wrap {
      background: #FFFFFF;
      padding:0.75rem;
      margin:0.75rem 0 0 0;
      border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
    }
    .group {
      display: flex;
      margin-top: 0.75rem;
      padding:0 0 1.25rem 0;
      border-bottom:0.0625rem dashed #D6D6DC;

      .image {
        width: 3.5rem;
        height: 3.5rem;
        border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
        border: 0.0625rem solid #D6D6DC;

        img {
          width:100%;
          height: 100%;
          border-radius: 0.5rem;
        }
      }

      .content {
        margin-left: 0.5rem;
        padding-top: 0.344rem;
        padding-bottom: 0.025rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;
        text-align: left;

        .name {
          font-size: 0.9375rem;
          font-weight: bold;
          color: #000000;
          letter-spacing: 0.8px;
        }

        .desc {
          font-size: 0.875rem;
          color: #6E6E79;
        }
      }

      .share {
        .share-box {
          width: 2rem;
          height: 2rem;
          background-color: #E8F4FC;
          border-radius: 50%;
          .icon-share {
            color:#2AA3FF;
          }
        }
      }
    }

    .group_type {
      padding:1.25rem 0 0 0;

      .group_top {
        display: flex;
        justify-content: space-between;
        font-size: 0.875rem;

        .p1 {
          font-weight: 500;
          color: #00001C;
        }

        .p2 {
          letter-spacing: 0.044rem;
          color:#6E6E79;
          span {
            color:#6E6E79;
          }
        }
      }

      .labels {
        display: flex;
        flex-wrap: wrap;
        padding:0.9375rem 0 0 0;

        .label {
          min-width: 4rem;
          box-sizing: border-box;
          background-color: #F5F5F5;
          border-radius: 0.375rem 0.375rem 0.375rem 0.375rem;
          margin: 0 0.5rem 0.5rem 0;
          font-size: 0.875rem;
          line-height: 0.875rem;
          color: #00001C;
          padding:0.5625rem 0.875rem;
          cursor: pointer;
        }
      }
    }
  }

  .explainWrapper {
    width: 15.625rem;
    max-height: 24rem;
    background-color: #fff;
    border-radius: 0.9375rem;
    transition: 0.3s;
    padding:1.125rem 0 1.875rem 0;
    position: relative;

    .header {
      height: 2.596rem;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;

      .img {
        width: 2.25rem;
        height: 2.25rem;
        margin-right: 0.625rem;

        img {
          width: 2.25rem;
          height: 2.25rem;
          border-radius: 50%;
        }
      }

      .title {
        font-size: 1rem;
        letter-spacing: 0.05rem;
        color: #000;
      }

      .icon-guanbi {
        position: absolute;
        top: 0.875rem;
        right: 1.25rem;
        color: #000;
      }
    }

    .content {
      max-height: 11rem;
      padding-top: 0.562rem;
      font-size: 0.875rem;
      letter-spacing: 0.066rem;
      color: #666;
      padding-left: 1.049rem;
      padding-right: 1.469rem;
      text-align: left;
      overflow-y: auto;
      // text-indent: 1.75rem;
      // line-height: 1.5rem;
    }

    .img {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 14rem;

      img {
        width: 13rem;
        height: 13rem;
      }
    }

    .kf_guide {
      max-height: 3rem;
      padding-top: 0.506rem;
      padding-left: 2.688rem;
      padding-right: 2.688rem;
      font-size: 0.875rem;
      letter-spacing: 0;
      color: #666;
      overflow-y: scroll;
    }
  }
  .poster-down {
    position: absolute;
    z-index: 99;
    bottom:-3.5rem;
    left:50%;
    transform: translateX(-50%);
    img {
      width: 2rem;
      height: 2rem;
      cursor: pointer;
    }
  }
  .shareWrapper {
    height: 29rem;
    width: 18rem;

    .imgContent {
      width: 18rem;
      height: 25rem;

      img {
        width: 18rem;
        height: 25rem;
      }
    }

    .divContent {
      width: 18rem;
      height: 25rem;
      padding: 3rem 1rem;
      background-image: url(../../../assets/images/member/qhm_sharepicbg@2x.png);
      background-size: cover;

      .header {
        height: 8rem;
        width: 16rem;

        .userInfo {
          display: flex;
          align-items: center;
          padding: 1rem 0 0 1rem;

          .image {
            .img {
              width: 2rem;
              height: 2rem;
              border-radius: 50%;
            }
          }

          .title {
            margin-left: 1rem;
            font-size: 1rem;
            color: #333;
          }
        }

        .desc {
          height: 4rem;
          text-align: left;
          padding: 0.3rem 1rem 2rem 1rem;
          color: #999;
          overflow: hidden;
          text-overflow: ellipsis;
          // display: -webkit-box;
          // -webkit-line-clamp: 3;
          // line-clamp: 3;
          // -webkit-box-orient: vertical;
        }
      }

      .footer {
        width: 7rem;
        height: 7rem;
        margin-top: 2rem;
        margin-left: 1rem;
        background-color: red;

        .canvas {
          width: 7rem;
          height: 7rem;
        }
      }
    }

    .close {
      height: 4rem;
      display: flex;
      align-items: flex-end;
      justify-content: center;

      .icon-adsystem_icon_cancle {
        font-size: 3rem;
        color: #fff;
        width: 3rem;
        height: 3rem;
      }
    }
  }

</style>
